﻿<%@ Page Language="C#" Async="true" AutoEventWireup="true" CodeBehind="index.aspx.cs" Inherits="YunShop_WebAPI.API.index" %>

<!DOCTYPE html>

<html xmlns="http://www.w3.org/1999/xhtml">
<meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=0">
<head runat="server">
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
    <title>获取小程序码</title>
</head>
<body style="padding-top: 17px;">
    <form id="form1" runat="server">
        <label style="font-size: 26px; float: left;">参数：</label><input type="text" id="parameter" style="width: 200px; font-size: 26px;" />
        <div onclick="onclick_image()" id="btnGen" style="cursor: pointer; display: inline-block; width: 85px; height: 40px; line-height: 40px; margin-left: 20; font-size: 18px; border-radius: 22px; background: #fafafa; border: 1px solid #808080; text-align: center">
            <span>生成</span>
        </div>
        <br />
        <img id="img" src="http://qkl.kailly.com/Images/nopic2.png" alt="小程序码" style="width: 400px; margin-top: 80px;" />
        <script type="text/javascript" src="http://qkl.kailly.com/Scripts/jquery/jquery-1.11.2.min.js"></script>
        <script type="text/javascript">
            var lock = false;
            function onclick_image() {
                console.log("onclick_image");
                if (lock) {
                    return;
                }
                lock = true;
                $.ajax({
                    url: "/mall/GenQRCode",
                    type: "POST",
                    contentType: "application/json; charset=utf-8", // 设置请求头，表明发送的是JSON数据  
                    dataType: "json", // 期望从服务器返回的数据类型  
                    data: JSON.stringify({
                        CorpID: $("#parameter").val()
                    }), // 将JSON对象转换为字符串 
                    success: function (res) {
                        lock = false;
                        console.log(res, "res")
                        if (res.Status == 1) {
                            const pic = res.Data.relDir;
                            console.log(pic, "pic")
                            $("#img").attr("src", location.origin
                                + pic);
                        } else {
                            $("#img").attr("src", "http://qkl.kailly.com/Images/nopic2.png");

                        }

                    },
                    error: function (err) {
                        lock = false;
                    }
                });
            }





        </script>
    </form>
</body>
</html>
